require 'rubygems'
gem 'soap4r'
require 'soap/wsdlDriver'
require 'soap/header/simplehandler'
require 'defaultDriver.rb'
require 'authStub.rb'

#Async create options
#options = CreateOptions.new(nil,nil,nil,nil,nil,nil,nil,nil,'Asynchronous')
options = nil

footer = "<table cellpadding='2' cellspacing='0' width='600' border='0' align='center'><tr><td valign='top' align='left' style='line-height: 16px;'><p><font face='verdana' size='1' color='#777777'>This email was sent to:  <b>%%emailaddr%%</b><br /><a href='%%subscription_center_url%%' alias='Manage Subscriptions'>Manage Subscriptions</a> | <a href='%%profile_center_url%%' alias='Update Profile'>Update Profile</a> | <a href='%%unsub_center_url%%' alias='Unsubscribe'>One-Click Unsubscribe</a></p><p>This email was sent by: <b>%%Member_Busname%%</b><br />%%Member_Addr%% %%Member_City%%, %%Member_State%% %%Member_PostalCode%% %%Member_Country%%</p><p>We respect your right to privacy - <a href='http://email.exacttarget.com/ETWeb/company.aspx?id=80' alias='View Privacy Policy' style='color: #0000ff'>view our policy</a></p></font></td><td width='145' align='right' valign='center'><a href='http://www.exacttarget.com' title='This email is Powered By ExactTarget' alias='Powered By'><img src='http://email.exacttarget.com/images/Powered_By_1206.jpg' width='124' height='55' alt='This email is Powered By ExactTarget' border='0' /></a></td></tr></table>"

Params = {
  :CustomerKey => "API-Test-9",
  :Name => "API-Test-9",
  :ID => nil,
  :ClonedFromID => 2723760,
  :Subject => "Thank you for subscribing",
  :HTMLBody => "<table width=\"600\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\" style=\"border-top: 1px solid #CCC; border-bottom: 1px solid #CCC; padding: 16px 0;\"><tbody><tr><td align=\"left\"><p>Now is the time for all good men to come to the aid of their country.</p><p>Now is the time for all good men to come to the aid of their country.</p><p>Now is the time for all good men to come to the aid of their country.</p><p>Now is the time for all good men to come to the aid of their country.</p><p>Now is the time for all good men to come to the aid of their country.</p></td></tr><tr><td align=\"left\"><custom type=\"content\" name=\"cell2\"></custom></td></tr></tbody></table><custom name=\"opencounter\" type=\"tracking\"></custom>" + footer
}

emailObj = Email.new(nil,nil,nil,nil,nil,Params[:ID],nil,Params[:CustomerKey],nil,nil,Params[:Name],nil,nil,Params[:HTMLBody],Params[:HTMLBody].gsub(/<\/?[^>]*>/,""),nil,Params[:Subject],nil,1)
apiObj = emailObj

resp = $driver.create(CreateRequest.new(options,[*apiObj]))